import random
import pygame

# 全局定义
SCREEN_X = 600
SCREEN_Y = 600

# 图案类
# 方法：清空/放置
# 点以25位单位
class Shape:
    def __init__(self):
        self.body = []
        self.recLeft = []
        self.recTop = []
        self.num = 0
    def remove(self):
        self.body = []
        self.recLeft = []
        self.recTop = []
        self.num = 0
    def set(self,level):
        allpos = []
        # 不靠墙太近 150 ~ SCREEN_X-150 之间
        for pos in range(150, SCREEN_X - 150, 150):
            allpos.append(pos)
        seed = random.choice(allpos)
        SEED = random.choice(allpos)
        if level==1:
            self.recLeft.append(0+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(50+seed)
            self.recTop.append(0+SEED)
            self.recTop.append(0+SEED)
            self.recTop.append(0+SEED)
            self.recTop.append(25+SEED)
            self.recTop.append(50+SEED)
        elif level==2:
            self.recLeft.append(0+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(50 + seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(0 + seed)
            self.recTop.append(0+SEED)
            self.recTop.append(0+SEED)
            self.recTop.append(0+SEED)
            self.recTop.append(25+SEED)
            self.recTop.append(25+SEED)
            self.recTop.append(25+SEED)
        elif level==3:
            self.recLeft.append(0+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(75+seed)
            self.recLeft.append(75+seed)
            self.recTop.append(75+SEED)
            self.recTop.append(75+SEED)
            self.recTop.append(50+SEED)
            self.recTop.append(50+SEED)
            self.recTop.append(25+SEED)
            self.recTop.append(25+SEED)
            self.recTop.append(0+SEED)
        elif level==4:
            self.recLeft.append(50+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(0+seed)
            self.recLeft.append(0+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(25+seed)
            self.recTop.append(50+SEED)
            self.recTop.append(50+SEED)
            self.recTop.append(50+SEED)
            self.recTop.append(25+SEED)
            self.recTop.append(25+SEED)
            self.recTop.append(25+SEED)
            self.recTop.append(0+SEED)
            self.recTop.append(0+SEED)
        elif level==5:
            self.recLeft.append(50+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(0+seed)
            self.recLeft.append(0+seed)
            self.recTop.append(25+SEED)
            self.recTop.append(0+SEED)
            self.recTop.append(0+SEED)
            self.recTop.append(25+SEED)
            self.recTop.append(50+SEED)
            self.recTop.append(75+SEED)
            self.recTop.append(100+SEED)
            self.recTop.append(100+SEED)
            self.recTop.append(75+SEED)
        elif level==6:
            self.recLeft.append(75+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(0+seed)
            self.recTop.append(0+SEED)
            self.recTop.append(0+SEED)
            self.recTop.append(25+SEED)
            self.recTop.append(50+SEED)
            self.recTop.append(75+SEED)
            self.recTop.append(75+SEED)
            self.recTop.append(50+SEED)
            self.recTop.append(25+SEED)
            self.recTop.append(0+SEED)
            self.recTop.append(0+SEED)
        elif level==7:
            self.recLeft.append(75+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(0+seed)
            self.recLeft.append(0+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(0+seed)
            self.recLeft.append(0+seed)
            self.recTop.append(0+SEED)
            self.recTop.append(0+SEED)
            self.recTop.append(0+SEED)
            self.recTop.append(0+SEED)
            self.recTop.append(25+SEED)
            self.recTop.append(25+SEED)
            self.recTop.append(25+SEED)
            self.recTop.append(50+SEED)
            self.recTop.append(50+SEED)
            self.recTop.append(50+SEED)
            self.recTop.append(75+SEED)
        elif level==8:
            self.recLeft.append(75+seed)
            self.recLeft.append(75+seed)
            self.recLeft.append(75+seed)
            self.recLeft.append(100+seed)
            self.recLeft.append(100+seed)
            self.recLeft.append(100+seed)
            self.recLeft.append(75+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(0+seed)
            self.recTop.append(100+seed)
            self.recTop.append(75+seed)
            self.recTop.append(50+seed)
            self.recTop.append(50+seed)
            self.recTop.append(25+seed)
            self.recTop.append(0+seed)
            self.recTop.append(0+seed)
            self.recTop.append(0+seed)
            self.recTop.append(25+seed)
            self.recTop.append(50+seed)
            self.recTop.append(50+seed)
            self.recTop.append(50+seed)
        elif level==9: # can't win
            self.recLeft.append(0+seed)
            self.recLeft.append(0+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(0+seed)
            self.recLeft.append(0+seed)
            self.recLeft.append(0+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(50+seed)
            self.recTop.append(25+SEED)
            self.recTop.append(0+SEED)
            self.recTop.append(0+SEED)
            self.recTop.append(0+SEED)
            self.recTop.append(25+SEED)
            self.recTop.append(50+SEED)
            self.recTop.append(50+SEED)
            self.recTop.append(50+SEED)
            self.recTop.append(75+SEED)
            self.recTop.append(100+SEED)
            self.recTop.append(100+SEED)
            self.recTop.append(100+SEED)
            self.recTop.append(75+SEED)
        elif level==10:
            self.recLeft.append(0+seed)
            self.recLeft.append(0+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(75+seed)
            self.recLeft.append(75+seed)
            self.recLeft.append(75+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(50+seed)
            self.recLeft.append(25+seed)
            self.recLeft.append(0+seed)
            self.recTop.append(25+SEED)
            self.recTop.append(50+SEED)
            self.recTop.append(50+SEED)
            self.recTop.append(75+SEED)
            self.recTop.append(100+SEED)
            self.recTop.append(100+SEED)
            self.recTop.append(100+SEED)
            self.recTop.append(75+SEED)
            self.recTop.append(50+SEED)
            self.recTop.append(50+SEED)
            self.recTop.append(25+SEED)
            self.recTop.append(0+SEED)
            self.recTop.append(0+SEED)
            self.recTop.append(0+SEED)

        for i in range(level+4):
            self.body.append(pygame.Rect(self.recLeft[i],self.recTop[i],25,25))